/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.srcptit.trainning.hanhpt.btvn1;

/**
 *
 * @author Administrator
 */
public class Bai8M1
{
    static boolean nguyento(int n)
    {
        if(n==0||n==1) return false;
       else
           for(int i=2;i<=(int) Math.sqrt(n);i++)
               if(n%i==0) return false;
               return true;
    }
    static boolean chuso(int n)
    {
        while(n>0)
        {
            if(!nguyento(n%10)) return false;
            n=n/10;
        }
        return true;
    }
    static boolean daykhonggiam(int n)
    {
       while(n>0)
       {
           if((n%10)<(n/10)%10) return false;
           n=n/10;
       }
       return true;
    }
    public static void main(String[] args) 
    {
        for(int i=1000000;i<=9999999;i++)
            if(nguyento(i)&&chuso(i)&&daykhonggiam(i))
                System.out.print(i+ " ");
    }
}
